import { getMoneyIncomePay } from "@/api/money"; // 导入资金信息相关接口

const money = {
  state: {
    addSwiperDialog: {
      title: "新增轮播信息",
      type: "add",
    },
    addFundDialog: {
      title: "新增资金信息",
      type: "add",
    },
    addUserDialog: {
      title: "新增员工信息",
      type: "add",
    },
    addTuijianDialog: {
      title: "新增车辆推荐",
      type: "add",
    },
    addJinDialog: {
      title: "新增精品推荐",
      type: "add",
    },
    search: {
      startTime: "",
      endTime: "",
      name: "",
    },
    searchBtnDisabled: true,
  },
  getters: {
    addFundDialog: (state) => state.addFundDialog,
    addTuijianDialog: (state) => state.addTuijianDialog,
    addJinDialog: (state) => state.addJinDialog,
    addUserDialog: (state) => state.addUserDialog,
    search: (state) => state.search,
    searchBtnDisabled: (state) => state.searchBtnDisabled,
  },
  mutations: {
    SET_DIALOG_TITLE: (state, type) => {
      if (type === "add") {
        state.addFundDialog.title = "新增";
        state.addFundDialog.type = "add";
      } else {
        state.addFundDialog.title = "编辑";
        state.addFundDialog.type = "edit";
      }
    },
    SET_JIN_DIALOG_TITLE: (state, type) => {
      if (type === "add") {
        state.addJinDialog.title = "新增";
        state.addJinDialog.type = "add";
      } else {
        state.addJinDialog.title = "编辑";
        state.addJinDialog.type = "edit";
      }
    },
    SET_SEARCH: (state, payload) => {
      state.search = payload;
    },
    SET_SEARCHBTN_DISABLED: (state, payload) => {
      state.searchBtnDisabled = payload;
    },
  },
  actions: {
    // 获取资金列表
    GetMoneyIncomePay({ commit }, reqData) {
      return new Promise((resolve) => {
        getMoneyIncomePay(reqData).then((response) => {
          const data = response.data;
          resolve(data);
        });
      });
    },
  },
};

export default money;
